package hhm.javamode.composite.duck;

/**
 * Created by Administrator on 2017/1/23.
 */
public class TestFlock {

	public static void main(String[] args) {

		CounterDuckFactory duckFactory = new CounterDuckFactory();

		Quackable mallQuackable = duckFactory.createMallardDuck(); // 定义绿头鸭
		Quackable reQuackable = duckFactory.createRedheadDuck(); // 定义红头鸭
		Quackable duckcall = duckFactory.createDuackcall(); // 定义鸭鸣器
		Quackable rubber = duckFactory.createRubberDuck(); // 定义橡皮鸭

		Quackable gooseDuck = new GooseAdapter(new Goose());

		Flock flock = new Flock(); // 首先将一群鸭子加入到flock中 ,这种鸭子包含了岁有的种类

		flock.add(mallQuackable);
		flock.add(reQuackable);
		flock.add(duckcall);
		flock.add(rubber);
		flock.add(gooseDuck);

		// 定义一群绿头鸭，仅仅含有绿头鸭

		Flock flockmallard = new Flock();

		Quackable mallardone = duckFactory.createMallardDuck();
		Quackable mallardtwo = duckFactory.createMallardDuck();
		Quackable mallardthree = duckFactory.createMallardDuck();
		Quackable mallardfour = duckFactory.createMallardDuck();
		Quackable mallardfive = duckFactory.createMallardDuck();

		flockmallard.add(mallardone);
		flockmallard.add(mallardtwo);
		flockmallard.add(mallardthree);
		flockmallard.add(mallardfour);
		flockmallard.add(mallardfive);

		// 将绿头鸭群 flockmallard加入到 flock中

		flock.add(flockmallard);

		System.out.println("整群鸭子叫：");
		flock.quack();

		System.out.println("绿头鸭群叫");
		flockmallard.quack();

		System.out.println("The Duck quacked " + QuackCounter.getQuacks() + " times");
	}

}
